package org.domain.sigepac.Entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.commons.lang3.time.DateUtils;

@Embeddable
public class FrequenciaVoluntarioId implements Serializable {

	private static final long serialVersionUID = 1328206633774965017L;

	@Column(name = "id_voluntario", nullable = false)
	private Integer idVoluntario;

	@Column(name = "id_turma", nullable = false)
	private Integer idTurma;

	@Temporal(TemporalType.DATE)
	@Column(name = "data", nullable = false)
	private Date data;

	public Integer getIdVoluntario() {
		return idVoluntario;
	}

	public void setIdVoluntario(Integer idVoluntario) {
		this.idVoluntario = idVoluntario;
	}

	public Integer getIdTurma() {
		return idTurma;
	}

	public void setIdTurma(Integer idTurma) {
		this.idTurma = idTurma;
	}

	public Date getData() {
		return data;
	}

	public void setData(Date data) {
		this.data = data;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((data == null) ? 0 : data.hashCode());
		result = prime * result + ((idVoluntario == null) ? 0 : idVoluntario.hashCode());
		result = prime * result + ((idTurma == null) ? 0 : idTurma.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		FrequenciaVoluntarioId other = (FrequenciaVoluntarioId) obj;
		if (data == null) {
			if (other.data != null)
				return false;
		} else if (!DateUtils.isSameDay(data,other.data))
			return false;
		if (idVoluntario == null) {
			if (other.idVoluntario != null)
				return false;
		} else if (!idVoluntario.equals(other.idVoluntario))
			return false;
		if (idTurma == null) {
			if (other.idTurma != null)
				return false;
		} else if (!idTurma.equals(other.idTurma))
			return false;
		return true;
	}

}
